<!doctype html>
<html>
<head scroll="no" style="overflow-x:hidden">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=320, initial-scale=1, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
	body{
		background: white;
		min-height:736px;
		position:relative;
		font-family: "AppleGothic","Heiti SC","Hiragino Sans GB";
	}
	.detail{
		background-color:#FFF;
		min-height:1400px;
		margin-top: 30px;
		margin-left: 16px;
	}
	.detail span{
		line-height: 30px;
		font-family:"AppleGothic";
		color:#555;
	}
  </style>
	</head>
<body>
<?php
	require_once(dirname(__FILE__)."/lib/mysql.php");
	
	$_PARA 	= array() ;
	if(array_key_exists('item_id',$_POST))	$_PARA 		= $_POST ;
	else									$_PARA 		= $_GET ;

	$item_id     = intval($_PARA['item_id']);
	if ($item_id == 0){
		echo "error no item_id ." ;
		exit(0) ;
	}

	sql_connect();

	$item = sql_fetch_one("select * from sys_item where `id` = $item_id") ;
	if (is_array($item) == false || array_key_exists("id", $item) == false){
		echo "error item_id not find." ;
		exit(0) ;
	}

	if (isset($_GET['req'])&&$_GET['req']=="ITEM_TIPS"||isset($_POST['req'])&&$_POST['req']=="ITEM_TIPS") {
		echo $item['tips'];
	}
	else{
		echo "<div class='detail'>";
		echo "<span>品名 : " . $item['name']."</span>";
		
		if (intval($item['brand_id']) > 0){
			echo "<br><span>品牌 : " . sql_fetch_one_cell("select `name` from grp_brand where `id` = '{$item['brand_id']}'")."</span>";
		}
		
//		if (strlen($item['gjj_code']) > 0){
//			echo "<br><span>编码 : " . substr($item['gjj_code'],-6)."</span>";
//		}
		if (strlen($item['id']) > 6){
			echo "<br><span>编码 : " . $item['id']."</span>";
		}
		else
		{
			echo "<br><span>编码 : " .sprintf("%06d",$item['id'])."</span>";
		}
		
		if (strlen($item['min_order_quantity']) > 0){
			echo "<br><span>起订量 : " . $item['min_order_quantity']."</span>";
		}
		if (intval($item['unit_id']) > 0){
			echo "<br><span>单位 : " . sql_fetch_one_cell("select `name` from grp_unit where `id` = '{$item['unit_id']}'")."</span>";
		}
		if (strlen($item['factory_code'])>0) {
			echo "<br><span>型号 : " . $item['factory_code']."</span>";
		}

		if (strlen($item['structure'])>0) {
			echo "<br><span>结构 : " . $item['structure']."</span>";
		}

		$sery = sql_fetch_rows("select g.`name` from sys_item_sery s left join grp_sery g on s.sery_id = g.`id` where s.`item_id` = '{$item['id']}'") ;
		if (count($sery) > 0){
			echo "<br><span>系列 : " ;
			$dh = "" ;
			foreach ($sery as $s){
				echo $dh.$s['name'] ;
				$dh = "," ;
			} 
			echo "</span>";
		}
		
		$style = sql_fetch_rows("select g.`name` from sys_item_style s left join grp_style g on s.style_id = g.`id` where s.`item_id` = '{$item['id']}'") ;
		if (count($style) > 0){
			echo "<br><span>风格 : " ;
			$dh = "" ;
			foreach ($style as $s){
				echo $dh.$s['name'] ;
				$dh = "," ;
			} 
			echo "</span>";
		}
		$color = sql_fetch_rows("select g.`name` from sys_item_color s left join grp_color g on s.color_id = g.`id` where s.`item_id` = '{$item['id']}'") ;
		if (count($color) > 0){
			echo "<br><span>色系 : " ;
			$dh = "" ;
			foreach ($color as $s){
				echo $dh.$s['name'] ;
				$dh = "," ;
			}
			echo "</span>";
		}
		$size = sql_fetch_rows("select size,volume from sys_item_size where item_id = '{$item['id']}'");
		if (count($size) > 0){
			$t=1;
			foreach ($size as $s) {
				echo "<br><span>规格".$t." : ".$s['size']."</span>";
				if (strlen($s['volume'])>0) {
					echo "<br><span>体积".$t." : ".$s['volume']."</span>";
				}
				$t++;
			}
			unset($t);
		}elseif (strlen($item['size'])>0){
			echo "<br><span>规格 : ".$item['size']."</span>";
			if (strlen($item['volume'])>0) {
				echo "<br><span>体积 : ".$item['volume']."</span>";
			}
		}
		//面料
		$str="";
		if($item['fabric_list']!="")
		{
			$t=str_replace(","," or id = ",$item['fabric_list']);
			$fabric=sql_fetch_rows("select * from base_sys_fabric where id = ".$t);
			if(count($fabric)>0)
			{
				foreach($fabric as $f)
				{
					if($str=="")
					{
						$str.=$f['name'];
					}
					else
					{
						$str.=",".$f['name'];
					}
				}
			}
			if($str!="")
			{
				echo "<br><span>面料 : ".$str."</span>";
			}
		}
			
		//材质
		$str="";
		if($item['material_list']!="")
		{
			$t=str_replace(","," or id = ",$item['material_list']);
			$material=sql_fetch_rows("select * from base_sys_material where id = ".$t);
			if(count($material)>0)
			{
				foreach($material as $m)
				{
					if($str=="")
					{
						$str.=$m['name'];
					}
					else
					{
						$str.=",".$m['name'];
					}
				}
			}
			if($str!="")
			{
				echo "<br><span>主材 : ".$str."</span>";
			}
		}
		//产地
		$str="";
		$place = sql_fetch_rows("select g.`name` from sys_item_place s left join grp_place g on s.place_id = g.`id` where s.`item_id` = '{$item['id']}'") ;
		if (count($place) > 0){
			echo "<br><span>产地 : " ;
			$dh = "" ;
			foreach ($place as $s){
				echo $dh.$s['name'] ;
				$dh = "," ;
			} 
			echo "</span>";
		}
		

		$ex_info=sql_fetch_rows("SELECT grp_item_ex.`name` AS ex_name, GROUP_CONCAT(item_ex_value) AS ex_value FROM `sys_item_info_ex` LEFT JOIN grp_item_ex ON grp_item_ex.id=sys_item_info_ex.item_ex_id WHERE item_id=".$item_id." GROUP BY grp_item_ex.`name`;");
		if(count($ex_info)>0){
			foreach ($ex_info as $ex) {
				echo "<br><span>".$ex['ex_name']." : ".$ex['ex_value']."</span>";
			}
		}

		if (strlen($item['package'])){
			echo "<br><span>包装件数 : " . $item['package']."</span>";
		}

		if (strlen($item['supply_cycle'])) {
			echo "<br><span>发货周期 : " . $item['supply_cycle']."</span>";
		}

		if (strlen($item['top_surface'])) {
			echo "<br><span>顶面工艺 : " . $item['top_surface']."</span>";
		}
		if (strlen($item['filling'])) {
			echo "<br><span>软体填充 : " . $item['filling']."</span>";
		}
		if (strlen($item['metals'])) {
			echo "<br><span>五金配件 : " . $item['metals']."</span>";
		}
		//涂装工艺
		$coating=sql_fetch_rows("select coating FROM base_sys_preview WHERE item_id = '{$item['id']}'");
		if (count($coating)&&$coating[0]['coating']!=null) {
			echo "<br><span>涂装工艺 : ";
			$dh = "" ;
			foreach ($coating as $value) {
				echo $dh.$value['coating'];
				$dh = "," ;
			}
			echo "</span>";
		}

		echo "</div>";

	}
?>
</body>
</html>
